home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / plnk081.zip / pilot-link.0.8.1 / Tcl / tclAppInit.c < prev    next >
C/C++ Source or Header  |  1997-06-29  |  3KB  |  122 lines

  1. /* 
  2.  * tclAppInit.c --
  3.  *
  4.  *    Provides a default version of the main program and Tcl_AppInit
  5.  *    procedure for Tcl applications (without Tk).
  6.  *
  7.  * Copyright (c) 1993 The Regents of the University of California.
  8.  * Copyright (c) 1994-1995 Sun Microsystems, Inc.
  9.  *
  10.  * See the file "license.terms" for information on usage and redistribution
  11.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  12.  *
  13.  * SCCS: @(#) tclAppInit.c 1.17 96/03/26 12:45:29
  14.  */
  15.  
  16. #include "tcl.h"
  17.  
  18. /*
  19.  * The following variable is a special hack that is needed in order for
  20.  * Sun shared libraries to be used for Tcl.
  21.  */
  22.  
  23. extern int matherr();
  24. int *tclDummyMathPtr = (int *) matherr;
  25.  
  26. EXTERN int        Pdapilot_Init _ANSI_ARGS_((Tcl_Interp *interp));
  27.  
  28. #ifdef TCL_TEST
  29. EXTERN int        Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp));
  30. #endif /* TCL_TEST */
  31.  
  32. /*
  33.  *----------------------------------------------------------------------
  34.  *
  35.  * main --
  36.  *
  37.  *    This is the main program for the application.
  38.  *
  39.  * Results:
  40.  *    None: Tcl_Main never returns here, so this procedure never
  41.  *    returns either.
  42.  *
  43.  * Side effects:
  44.  *    Whatever the application does.
  45.  *
  46.  *----------------------------------------------------------------------
  47.  */
  48.  
  49. int
  50. main(argc, argv)
  51.     int argc;            /* Number of command-line arguments. */
  52.     char **argv;        /* Values of command-line arguments. */
  53. {
  54.     Tcl_Main(argc, argv, Tcl_AppInit);
  55.     return 0;            /* Needed only to prevent compiler warning. */
  56. }
  57.  
  58. /*
  59.  *----------------------------------------------------------------------
  60.  *
  61.  * Tcl_AppInit --
  62.  *
  63.  *    This procedure performs application-specific initialization.
  64.  *    Most applications, especially those that incorporate additional
  65.  *    packages, will have their own version of this procedure.
  66.  *
  67.  * Results:
  68.  *    Returns a standard Tcl completion code, and leaves an error
  69.  *    message in interp->result if an error occurs.
  70.  *
  71.  * Side effects:
  72.  *    Depends on the startup script.
  73.  *
  74.  *----------------------------------------------------------------------
  75.  */
  76.  
  77. int
  78. Tcl_AppInit(interp)
  79.     Tcl_Interp *interp;        /* Interpreter for application. */
  80. {
  81.     if (Tcl_Init(interp) == TCL_ERROR) {
  82.     return TCL_ERROR;
  83.     }
  84.     if (Pdapilot_Init(interp) == TCL_ERROR) {
  85.     return TCL_ERROR;
  86.     }
  87.  
  88. #ifdef TCL_TEST
  89.     if (Tcltest_Init(interp) == TCL_ERROR) {
  90.     return TCL_ERROR;
  91.     }
  92.     Tcl_StaticPackage(interp, "Tcltest", Tcltest_Init,
  93.             (Tcl_PackageInitProc *) NULL);
  94. #endif /* TCL_TEST */
  95.  
  96.     /*
  97.      * Call the init procedures for included packages.  Each call should
  98.      * look like this:
  99.      *
  100.      * if (Mod_Init(interp) == TCL_ERROR) {
  101.      *     return TCL_ERROR;
  102.      * }
  103.      *
  104.      * where "Mod" is the name of the module.
  105.      */
  106.  
  107.     /*
  108.      * Call Tcl_CreateCommand for application-specific commands, if
  109.      * they weren't already created by the init procedures called above.
  110.      */
  111.  
  112.     /*
  113.      * Specify a user-specific startup file to invoke if the application
  114.      * is run interactively.  Typically the startup file is "~/.apprc"
  115.      * where "app" is the name of the application.  If this line is deleted
  116.      * then no user-specific startup file will be run under any conditions.
  117.      */
  118.  
  119.     Tcl_SetVar(interp, "tcl_rcFileName", "~/.pitclrc", TCL_GLOBAL_ONLY);
  120.     return TCL_OK;
  121. }
  122.